{echo:JS::import('dialog?skin=brief');}
{echo:JS::import('dialogtools');}
{echo:JS::import('form');}
{echo:JS::import('date');}
<style type="text/css">
    #table_option td{
        width: 8px;
        height: 8px;
        background: #ddd;
        border:1px #999 solid;
        cursor: pointer;
    }
</style>

<h1 class="page_title">{$title}</h1>

<form action="{url:/app/category_save}" method="post" id="appForm" enctype="multipart/form-data">
	
	<div id="obj_form" class="form2">
		<dl class="lineD">
	    <dt>类别：</dt>
	    <dd>
	    	<select name="sel_category" id="sel_category">
	    		<option value="0">--请选择类别--</option>
	    	{query:name=goods_category where=parent_id eq 0}
	    		{if:$item['id']==$obj['category_id']}
	    			<option value="{$item[id]}" selected="selected">{$item['name']}</option>
	    		{else:}
	    			<option value="{$item[id]}">{$item['name']}</option>
	    		{/if}
	    		
	    	{/query}
	    	</select>
	    </dd>
	    </dl>
	    
	    <dl class="lineD">
	    <dt>店铺：</dt>
	    <dd>
	    	<select name="sel_seller" id="sel_seller">
	    		<option value="0">--请选择店铺--</option>
	    		{list:items=$seller_list}
	    			{if:$item['did']==$dp_id}
	    				<option value="{$item['did']}" selected="selected">{$item['dp_name']}</option>
	    			{else:}
	    				<option value="{$item['did']}">{$item['dp_name']}</option>
	    			{/if}
	    		{/list}
	    	</select>
	    </dd>
	    </dl>
	    
	    <dl class="lineD">
	    <dt>顺序：</dt>
	    <dd>
	    	<input type="text" id="order" name="order" value="{$obj['order']|'0'}" class="big" >
	    </dd>
	    </dl>
	    
	    <div style="text-align:center">
	    	<input type="hidden" name="id" value="{$obj['id']}"/>
	    	<input onclick="return check();" type="submit" value="提交" class="button">&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置" class="button">
	    </div>
	</div>

</form>


<script type="text/javascript">

$(function(){
	$("#sel_category").change(function(){
		var category_id = $("#sel_category").val();
		
		$.post("{url:/app/get_seller_by_category_id}",{category_id:category_id},function(data){
			var str = '', i;
			if(data.length<1)
			{
				$("#sel_seller").html("<option value='0'>--请选择店铺--</option>");
			}
			else
			{
				for(i=0,c=data.length; i<c; i++)
				{
					str += "<option value='"+data[i]['did']+"'>"+data[i]['dp_name']+"</option>";
				}
				$("#sel_seller").append( str );
			}
			
			/*
			if(data['status']=='success'){
				art.dialog({id:'withdraw-dialog'}).close();
				window.location.href = "{url:/ucenter/account/rand/}"+Math.random()+"#tab-1";
			}else{
				alert(data['msg']);
			}
			*/
		},'json');
	});
});


function check()
{
	var sel_category = $("#sel_category").val();
	var sel_seller = $("#sel_seller").val();
	if(sel_category == 0)
	{
		alert('请选择类别');
		return false;
	}
	
	if(sel_seller == 0)
	{
		alert('请选择店铺');
		return false;
	}

	
}
/*
var str='';
function selectUp(id)
{
	str +=id+"|";
	$("#sel").val(str);
}
function goods_select(gid)
{
  art.dialog.open('{url:/app/radio_goods_select?gid='+gid+'}',{id:'goods_select',title:'选择商品：',width:900,height:500,padding:'10px'});
}

function check()
{
	if($("#title").val() == "")
	{
		$(".invalid-msg").remove();
		$("#title").after("<label class='invalid-msg'>标题不能为空</label>");
		return false;
	}
	else
	{
		$("#title").next().remove();
	}


	if($("#sel_category").val() == '0')
	{
		$(".invalid-msg").remove();
		$("#sel_category").after("<label class='invalid-msg'>请选择商品分类</label>");
		return false;
	}
	else
	{
		$("#sel_category").next().remove();
	}
	
	
	if($("#upImg1").val() == "")
	{
		$(".invalid-msg").remove();
		$("#upImg1").after("<label class='invalid-msg'>图片不能为空</label>");
		return false;
	}
	else
	{
		$("#upImg1").next().remove();
	}

	if($("#link1").val() =="")
	{
		$(".invalid-msg").remove();
		$("#link1").next().after("<label class='invalid-msg'>关联商品不能为空</label>");
		return false;
	}
	else
	{
		$(".invalid-msg").remove();
	}

	
	if($("#upImg2").val() == "")
	{
		$(".invalid-msg").remove();
		$("#upImg2").after("<label class='invalid-msg'>图片不能为空</label>");
		return false;
	}
	else
	{
		$("#upImg2").next().remove();
	}


	if($("#link2").val() =="")
	{
		$(".invalid-msg").remove();
		$("#link2").next().after("<label class='invalid-msg'>关联商品不能为空</label>");
		return false;
	}
	else
	{
		$(".invalid-msg").remove();
	}

	
	if($("#upImg3").val() == "")
	{
		$(".invalid-msg").remove();
		$("#upImg3").after("<label class='invalid-msg'>图片不能为空</label>");
		return false;
	}
	else
	{
		$("#upImg3").next().remove();
	}

	if($("#link3").val() =="")
	{
		$(".invalid-msg").remove();
		$("#link3").next().after("<label class='invalid-msg'>关联商品不能为空</label>");
		return false;
	}
	else
	{
		$(".invalid-msg").remove();
	}

	$("#selLink").val($("#link1").val()+","+$("#link2").val()+","+$("#link3").val());
	
	if($("#order").val()=="" || isNaN($("#order").val()))
	{
		$("#order").after("<label class='invalid-msg'>不能为空且必须为数字</label>");
		return false;
	}
	else
	{
		$(".invalid-msg").remove();
	}	
}
*/


$("#table_option td:eq({$contents[0]['position']})").css("background","#000");
</script>